class Solution(object):
    def findMaxConsecutiveOnes(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        DP0 = 0
        DP1 = 0
        max_val = 0
        n = len(nums)
        for i in range(n):
            if nums[i] == 1:
                DP0 += 1
                DP1 += 1
                max_val = max(max_val, DP0, DP1)
            else:
                DP1 = DP0 + 1
                DP0 = 0
                max_val = max(max_val, DP0, DP1)
        return max_val


data = Solution()
nums = [1, 0, 1, 1, 0]
print(data.findMaxConsecutiveOnes(nums))
